package com.zbcbms.common;

import com.zbcbms.entity.tableData.BookTableData;
import javafx.collections.ObservableList;
import javafx.scene.control.*;

/**
 * @author fengq
 */
public class TableInitCommon {



    public void  homeTableInit(TableView<BookTableData> searchTableView,
                               TableColumn<BookTableData,String> searchTableCode,
                               TableColumn<BookTableData,String> searchTableBookName,
                              TableColumn<BookTableData,String> searchTableStatus,
                               TableColumn<BookTableData,String> searchTableAuthor,
                               TableColumn<BookTableData,String> searchTablePublishName,
                              TableColumn<BookTableData,String> searchTableYear,
                               TableColumn<BookTableData,String> searchTablePrice,
                               TableColumn<BookTableData,String> searchTableCategory,
                               ObservableList<BookTableData> data){
        searchTableCode.setCellValueFactory(cellData->cellData.getValue().getBookNumber());
        searchTableBookName.setCellValueFactory(cellData->cellData.getValue().getBookName());
        searchTableStatus.setCellValueFactory(cellData->cellData.getValue().getStatus());
        searchTableAuthor.setCellValueFactory(cellData->cellData.getValue().getAuthor());
        searchTablePublishName.setCellValueFactory(cellData->cellData.getValue().getPublishingHouse());
        searchTableYear.setCellValueFactory(cellData->cellData.getValue().getPublishingTime());
        searchTablePrice.setCellValueFactory(cellData->cellData.getValue().getPrice());
        searchTableCategory.setCellValueFactory(cellData->cellData.getValue().getType());
        searchTableView.setItems(data);
    }

    public void  homeTableInit(TableView<BookTableData> searchTableView,
                               TableColumn<BookTableData,String> searchTableCode,
                               TableColumn<BookTableData,String> searchTableBookName,
                               TableColumn<BookTableData,String> searchTableStatus,
                               TableColumn<BookTableData,String> searchTableAuthor,
                               TableColumn<BookTableData,String> searchTablePublishName,
                               TableColumn<BookTableData,String> searchTableYear,
                               TableColumn<BookTableData,String> searchTablePrice,
                               TableColumn<BookTableData,String> searchTableCategory){
        searchTableCode.setCellValueFactory(cellData->cellData.getValue().getBookNumber());
        searchTableBookName.setCellValueFactory(cellData->cellData.getValue().getBookName());
        searchTableStatus.setCellValueFactory(cellData->cellData.getValue().getStatus());
        searchTableAuthor.setCellValueFactory(cellData->cellData.getValue().getAuthor());
        searchTablePublishName.setCellValueFactory(cellData->cellData.getValue().getPublishingHouse());
        searchTableYear.setCellValueFactory(cellData->cellData.getValue().getPublishingTime());
        searchTablePrice.setCellValueFactory(cellData->cellData.getValue().getPrice());
        searchTableCategory.setCellValueFactory(cellData->cellData.getValue().getType());
    }




}
